<template>
  <div class="app-container">
    <!-- 商品名 -->
    <el-table ref="table" :data="crud.data" size="small">
      <el-table-column prop="prodId" label="产品编号" />
      <el-table-column prop="prodName" label="产品名称" />
      <el-table-column prop="prodType" label="产品类型" />
      <el-table-column prop="prodBatch" label="产品批次号" />
    </el-table>
  </div>
</template>

<script>
import crudProduct from '@/api/product'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
const defaultForm = { prodId: null, prodName: null, prodType: null, prodBatch: null, prodUnit: null, prodPrice: null, prodMemo: null }
export default {
  name: 'Dicproduct1',
  components: { },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  props: {
    cid: {
      type: String,
      default: ''
    }
  },
  cruds() {
    return CRUD({ queryOnPresenterCreated: false, title: '产品信息', url: 'api/product', idField: 'prodId', sort: 'prodId,desc', crudMethod: { ...crudProduct }})
  },
  data() {
    return {
      queryTypeOptions: [
        { key: 'prodId', display_name: '产品编号' }
      ]
    }
  },
  watch: {
    'cid'() {
      this.crud.params = { prodId: this.cid }
      this.crud.toQuery()
    }
  },
  created() {
    this.crud.params = { prodId: this.cid }
    this.crud.toQuery()
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
